package org.dce.screencapturer.objects;

import java.awt.AWTEvent;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.event.MouseWheelEvent;
import java.awt.geom.RoundRectangle2D;

import org.dce.screencapturer.actions.drawing.InsertObjectAction;
import org.dce.screencapturer.util.IconFactory;

@SuppressWarnings("serial")
public class RoundedBox extends RegularShapeObject {

	public static final class InsertAction extends InsertObjectAction {
		public InsertAction(){
			super("actions.roundedBox",IconFactory.getIcon("/images/box.png"), null,RoundedBox.class);
		}
	};

	private int cornerSize = 10;
	
	public RoundedBox(){
		enableEvents(AWTEvent.MOUSE_WHEEL_EVENT_MASK);
	}
	
	@Override
	protected Shape getShape() {
		
		Rectangle bounds = getDotsBounds();
		
		return new RoundRectangle2D.Float(
			bounds.x,
			bounds.y,
			bounds.width,
			bounds.height,
			cornerSize,
			cornerSize);
	}

	@Override
	protected void processMouseWheelEvent(MouseWheelEvent e) {
		
		int amount = e.getWheelRotation() * 2;
		
		if (cornerSize + amount > 0){
			cornerSize += amount;
		}
		
		repaint();
		
		super.processMouseWheelEvent(e);
	}
	

}
